/**
 * 
 */
package com.jie.eclipse.pan.swtitem.table;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.TableItem;

import com.jie.eclipse.pan.data.BaseDataEntity;
import com.jie.eclipse.pan.utils.StringHelper;
/**
 * @author yanjie
 *
 */
public class PTableViewer extends TableViewer{

	/**
	 * @param table
	 */
	public PTableViewer(PTable table) {
		super(table);
	}

	public PTable getPTable(){
		return (PTable)this.getTable();
	}
	
	public String getNextId(){
		int i = 0;
		for (int j = 0; j < this.getPTable().getItemCount(); j++) {
			TableItem item = this.getPTable().getItem(j);
			if(item.getData() instanceof BaseDataEntity){
				BaseDataEntity row = (BaseDataEntity)item.getData();
				if(row.gpsv("id").startsWith("col")){
					String index = row.gpsv("id").replace("col", "");
					if(StringHelper.isNumber(index, "dot:0")){
						if(i < Integer.parseInt(index)){
							i = Integer.parseInt(index);
						}
					}
				}
			}
		}
		return "col"+(i+1);
	}
}
